package com.herch.web.controller.monitor;

import com.herch.common.annotation.Log;
import com.herch.common.core.controller.BaseController;
import com.herch.common.core.domain.AjaxResult;
import com.herch.common.core.page.TableDataInfo;
import com.herch.common.enums.BusinessType;
import com.herch.common.utils.poi.ExcelUtil;
import com.herch.system.domain.HqMonitorData;
import com.herch.system.service.IHqMonitorDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 荧光模拟量温度监控数据Controller
 * 
 * @author ruoyi
 * @date 2023-12-25
 */
@RestController
@RequestMapping("/analyse/data")
public class HqMonitorDataController extends BaseController
{
    @Autowired
    private IHqMonitorDataService hqMonitorDataService;

    /**
     * 查询荧光模拟量温度监控数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HqMonitorData hqMonitorData)
    {
        startPage();
        List<HqMonitorData> list = hqMonitorDataService.selectHqMonitorDataList(hqMonitorData);
        return getDataTable(list);
    }

    /**
     * 导出荧光模拟量温度监控数据列表
     */
    @Log(title = "模拟量监控数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HqMonitorData hqMonitorData)
    {
        List<HqMonitorData> list = hqMonitorDataService.selectHqMonitorDataList(hqMonitorData);
        ExcelUtil<HqMonitorData> util = new ExcelUtil<HqMonitorData>(HqMonitorData.class);
        util.exportExcel(response, list, "模拟量监控数据");
    }

    /**
     * 获取荧光模拟量温度监控数据详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hqMonitorDataService.selectHqMonitorDataByID(id));
    }


    /**
     * 修改荧光模拟量温度监控数据
     */
    @Log(title = "模拟量监控数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HqMonitorData hqMonitorData)
    {
        return toAjax(hqMonitorDataService.updateHqMonitorData(hqMonitorData));
    }

    /**
     * 删除荧光模拟量温度监控数据
     */
    @Log(title = "模拟量监控数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hqMonitorDataService.deleteHqMonitorDataByIDs(ids));
    }

    @Log(title = "操作日志", businessType = BusinessType.CLEAN)
    @DeleteMapping("/clean")
    public AjaxResult clean()
    {
        hqMonitorDataService.cleanHistoryData();
        return success();
    }
    @GetMapping("/echartsData")
    public AjaxResult formatEchartsData(HqMonitorData hqMonitorData){
        Map<String,Object> map = hqMonitorDataService.formatEchartsData(hqMonitorData);
        return success(map);
    }
}
